<template>
  <div class="loginOut">
    <van-nav-bar
        title="设置"
        left-text="返回"
        right-text=""
        left-arrow
        @click-left="back"
    />
    <div class="setting-box">
      <van-cell-group>
        <van-cell title="当前登录账号：" :value="user" icon="location-o" />
        <van-button id="login-out" type="danger" size="large" @click="loginOut">退出登录</van-button>
      </van-cell-group>
    </div>
  </div>
</template>

<script>
  import { Cell, CellGroup,Button,NavBar } from 'vant';

  export default {
    name: "index",
    data() {
      return {
        user:''
      }
    },
    created: function () {
      this.user = sessionStorage.getItem('name');
    },
    methods: {
      loginOut(){
        sessionStorage.removeItem('token');
        sessionStorage.removeItem('name');
        sessionStorage.removeItem('cityId');
        this.$router.push({path:'/login/index'});
      },
      back(){
        this.$router.go(-1)
      }
    },
    components: {
      [CellGroup.name]:CellGroup,
      [Cell.name]:Cell,
      [Button.name]:Button,
      [NavBar.name]:NavBar
    }
  }
</script>

<style scoped>
  .setting-box{
    padding:0 .1rem;
  }
  #login-out{
    margin-top: .2rem;
  }
</style>
